//Magnat edition
function log_get(){
$('#logmodresult').val('');
$('#lcols').text('0');
var i=0;
var result;
var s = $('#log_list').find('tr');
var lcol = s.length;
for(var i=0;i<s.length;i++){
var lognum = $($(s[i]).find('td')[0]).text();
var logdate = $($(s[i]).find('td')[3]).text();
result += lognum+" : "+logdate+"\r\n";
}
result = result.replace('undefined','');
$('#logmodresult').val(result);
$('#lcols').text(lcol);
};

function get_roles(){
$('#logmodresult').val('');
$('#lcols').text('0');
var lgrole = $('.players-list').find('li');
var reslgs;
for(var i=0;i<lgrole.length;i++){
    var roles = $(lgrole[i]).find('div:first').attr('title');
    var nicks = $(lgrole[i]).find('.name').text();
    reslgs += nicks+" : "+roles+"\r\n";
}
reslgs = reslgs.replace('undefined','');
$('#logmodresult').val(reslgs);
};

function uni_ip(){
$('#logmodresult').val('');
$('#lcols').text('0');
var i=0;
var art = [];
var uni = [];
var s = $('#log_list').find('tr');
var lcol = s.length;
for(var i=0;i<s.length;i++){
var logip = $($(s[i]).find('td')[4]).text();
art[i] = logip;
};
$.each(art, function(i, el){
if($.inArray(el, uni) === -1)
uni.push(el);
});
$('#logmodresult').val(uni);
};

function list_ip(){
$('#logmodresult').val('');
$('#lcols').text('0');
var i=0;
var result;
var s = $('#log_list').find('tr');
var lcol = s.length;
for(var i=0;i<s.length;i++){
var logdate = $($(s[i]).find('td')[3]).text();
var logip = $($(s[i]).find('td')[4]).text();
result += logdate+" : "+logip+"\r\n";
}
result = result.replace('undefined','');
$('#logmodresult').val(result);
$('#lcols').text(lcol);
};

var newbtn = '<div class="inline" style="padding-right:4px;"><img src="http://www.iconsearch.ru/uploads/icons/softwaredemo/16x16/shield_red.png" width="16" height="16" style="vertical-align: middle; padding-right:5px" /><a style="text-decoration:underline;" id="modmenu" hidefocus="true" onfocus="this.blur();" ondblclick="return false">Moderating</a></div>';
$('.footer-links').prepend(newbtn);

var popupcheat = '<div id="wnd_cheat" class="popup-move clans-popup ui-draggable" style="top: 100%; margin-top:-281px; right: 5px; display: block; z-index: 10; height:335px; width:280px;">';
popupcheat += '<div class="popup-bg" style="text-align: center;">';
popupcheat += '<span style="font-size: 20px;"><img src="http://www.iconsearch.ru/uploads/icons/iconshock_finding_nemo_free_icons/32x32/findingnemo2.png" width="32" height="32" style="vertical-align: middle; padding-right:5px" />Moderating Toolset<img src="http://www.iconsearch.ru/uploads/icons/iconshock_finding_nemo_free_icons/32x32/findingnemo2.png" width="32" height="32" style="vertical-align: middle; padding-left:5px" /></span>';
popupcheat += '<p><span style="font-size: 16px; font-weight: bold;">Выгрузка логов</span></p><p><span>Список логов:</span><br /><textarea id="logmodresult" cols="20" rows="5"></textarea></p><p><span>Кол-во логов: </span><span id="lcols">0</span></p>';
popupcheat += '<p><button id="gtlogbtn" class="button" onclick="log_get()" ondblclick="return false">Выгрузить логи</button>&nbsp;&nbsp;&nbsp;<button id="gtlogbtn" class="button" onclick="get_roles()" ondblclick="return false">Выгрузить роли</button></p>';
popupcheat += '<p><button id="gtlogbtn" class="button" onclick="uni_ip()" ondblclick="return false">Уникально IP</button>&nbsp;&nbsp;&nbsp;<button id="gtlogbtn" class="button" onclick="list_ip()" ondblclick="return false">Списком IP</button></p>';
popupcheat += '2014&nbsp;&copy;&nbsp;Avernus =)';
popupcheat += '<a id="closecheat" onclick="$(\'#wnd_cheat\').remove();" class="popup-close" hidefocus="true"></a>';
popupcheat += '</div></div>';

$('#modmenu').click(function(){
$('#popup_container').append(popupcheat);
$('#wnd_cheat').draggable();
});